//
//  FindLayout.swift
//  SeeFM_Swift
//
//  Created by CBCT_MBP on 2022/3/2.
//

import UIKit

class SFBroadcastLayout: UICollectionViewFlowLayout {

    var scale: CGFloat?
    
    open override func prepare() {
        super.prepare()
        
        if let short = self.scale {
            self.collectionView?.decelerationRate = .fast
            //使用kvc
            if ((self.collectionView?.value(forKey: "interpageSpacing") as? CGSize) != nil) {
                let size = self.scrollDirection == .horizontal ? CGSize(width: -short,height: 0) : CGSize(width: 0 ,height: -short)
                self.collectionView?.setValue(size, forKey: "interpageSpacing")
            }
            if ((self.collectionView?.value(forKey: "pagingOrigin") as? CGPoint) != nil) {
                self.collectionView?.setValue(CGPoint.zero, forKey: "pagingOrigin")
            }
        }
    }
}
